<?php 
class getFaqAction extends AjaxAction{
	private $data = array();
	public function execute($request){
		$this->data['pagination']	= array(
				'page'		=> $request->getParameter('page', 1),
				'limit'		=> $request->getParameter('limit', sfConfig::get('app_faq_list_limit')),
				'page_show'	=> 5,
				'total'		=> 0,
				'router'	=> '',
				'params'	=> array()
		);
		$cateIds = $request->getParameter('cate_id','0');
		$arrCateId = explode(',', $cateIds);
		$str = '-1';
		foreach($arrCateId as $val){
			if(intval($val)==-1) continue;
			$str .=','.ArrayHelper::getStringIdsMultiLevel(array('id' => $val, 'children' => FaqCates::getCates(array('id'=>$val))));
		}
		$this->data['search']	= array(
					'cate_ids_in'			=> $str,
					'notempty'				=> '1'
				);
	 	//print_r($this->data);die;
		$this->data['list']						= FaqsTable::getDataListFrontend($this->data['search'],$this->data['pagination']['page'],$this->data['pagination']['limit']);
		$this->data['pagination']['total']		= FaqsTable::getDataListCountFrontend($this->data['search']);
		
		$pag	= new PaginationHelper2($this->data['pagination']);
		$this->data['pagination']['next_page']		= $pag->getNextPage();
		$this->data['pagination_pager']	= $pag->getPaginations();
		
		//echo '<pre>';print_r($this->data);die;
		
		return $this->renderPartial('getFaq', array('data' => $this->data));
	}
}